using System.Text.RegularExpressions;

namespace Ausy.Silverlight.Survey.Common.Validation
{
    public class RegexValidator : ValidatorBase<string>
    {
        public Regex Expression { get; set; }

        public RegexValidator()
        {
            this.DefaultMessage = "Ce champs n'est pas au bon format";
        }

        public override bool Validate(string value)
        {
            if (string.IsNullOrEmpty(value))
                return false;

            if (this.Expression != null)
                return this.Expression.IsMatch(value);

            return false;
        }
    }
}
